meson: cups: use cups-config for looking up cups
authorChristoph Reiter <creiter@src.gnome.org>
Mon, 1 Jul 2019 19:52:06 +0000 (21:52 +0200)
committerChristoph Reiter <creiter@src.gnome.org>
Mon, 1 Jul 2019 19:52:06 +0000 (21:52 +0200)
We were looking for the cups headers and the cups lib in the default locations
which for example breaks with OpenBSD where the cups headers are under /usr/local/include/

Instead just use the "cups" dependency type from meson which internally uses cups-config.

See #1967

Ported to master from !963

modules/printbackends/meson.build

index 2946960d2e671402589157af99435500f4c3ff59..c8c56454d64b52e0a6bf4d00049b431fa23741b9 100644 (file)
@@ -17,24 +17,8 @@ print_backends = ['file']
 # Checks to see if we should compile with CUPS backend for GTK
 enable_cups = enabled_print_backends.contains('cups')
 if enable_cups
-  #cups_config = find_program('cups-config', required : true)
-  #if cups_config.found()
-  # FIXME: eek, see configure.ac (we're just not going to support non-standar prefix for now)
-  #endif
-  if cc.has_header('cups/cups.h')
-    # TODO: include_directories from cups-config
-    cups_major_version = cc.compute_int('CUPS_VERSION_MAJOR', prefix : '#include <cups/cups.h>')
-    cups_minor_version = cc.compute_int('CUPS_VERSION_MINOR', prefix : '#include <cups/cups.h>')
-    message('Found CUPS version: @0@.@1@'.format(cups_major_version, cups_minor_version))
-    if cups_major_version < 2
-      cups_error = 'Need CUPS version >= 2.0'
-    else
-      libcups = cc.find_library('cups', required : true)
-      print_backends += ['cups']
-    endif
-  else
-    error('Cannot find CUPS headers in default prefix.')
-  endif
+  cups_dep = dependency('cups', version : '>=2.0', required: true)
+  print_backends += ['cups']
 endif
 
 # Checks to see if we should compile with cloudprint backend for GTK
@@ -93,7 +77,7 @@ if print_backends.contains('cups')
                 'gtkcupsutils.c',
                 'gtkcupssecretsutils.c',
                 c_args: printbackends_args,
-                dependencies: [libgtk_dep, libcups, colord_dep],
+                dependencies: [libgtk_dep, cups_dep, colord_dep],
                 install_dir: printbackends_install_dir,
                 install : true)
 endif